package bishi.didi;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/10/10 19:39
 */
public class two {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();sc.nextLine();
        int[] nums = new int[n];
        String s = sc.nextLine();
        for(int i=0;i<n;i++){
            nums[i] = s.charAt(i)-'0';
        }
        // 并查集
        int[] nnn = new int[n];
        for(int i=0;i<n;i++){
            nnn[i] = i-1;
        }
        for(int i=1;i<n;i++){
            if(nnn[i]==-1) continue;
            if(nums[nnn[i]]==nums[i]-1){
                nums[nnn[i]]=-1;
                nums[i] = -1;
                if(i<n-1){
                    nnn[i+1] = nnn[nnn[i]];
                }
            }
        }
        int max = 0;
        int sum = 0;
        for(int i=0;i<n;i++){
            if(nums[i]==-1){
                sum++;
            }
            max = Math.max(max,sum);
            if(nums[i]!=-1){
                sum=0;
            }
        }
        System.out.println(max);
    }
}
